package com.team11.server.controller.teacher;

import com.team11.server.pojo.InformationLIst;
import com.team11.server.pojo.LInformation;
import com.team11.server.pojo.dto.RespBean;
import com.team11.server.pojo.dto.RespPageBean;
import com.team11.server.service.ICInformationService;
import com.team11.server.service.ILInformationService;
import com.team11.server.service.ISInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mahongtao
 * @since 2021-06-17
 */
@CrossOrigin
@RestController
@RequestMapping("/teacher")
@Api(tags = "教师接口")
public class TeacherLInformationController {

    @Autowired
    private ILInformationService informationService;

    @Autowired
    ISInformationService isInformationService;

    @Autowired
    private ICInformationService icInformationService;

    @ApiOperation(value = "请假管理：获取请假管理的记录（分页）")
    @GetMapping("/")
    public RespPageBean getLinformation(@RequestParam(defaultValue = "1") Integer currentPage,
                                        @RequestParam(defaultValue = "10") Integer size,
                                        InformationLIst informationLIst,
                                        LocalDate startTime,
                                        LocalDate endTime){
        return informationService.getLInformationByPage(currentPage,size,informationLIst,startTime,endTime);

    }

    @ApiOperation(value = "请假管理：获取所有的请假原因")
    @GetMapping("/getReason")
    public List<String> getReason() {
        List<String> list = (List<String>) informationService.getReason();
        return list;
    }

    @ApiOperation(value = "请假管理：获取所有审批的状态")
    @GetMapping("/getStatus")
    public List<Integer> getStatus() {
        List<Integer> list= (List<Integer>) informationService.getStatus();
        return list;
    }

    @ApiOperation(value = "请假管理:根据请假id审批请假记录")
    @GetMapping("/approval")
    public RespBean approval(@RequestParam(value = "lId") List<Integer> lId
            , @RequestParam(value = "status") Integer status
            ,  String failReason){
        return informationService.approval(lId,status,failReason);
    }

    @ApiOperation(value = "请假管理：根据学生id查询请假详情")
    @GetMapping("/detail")
    public List getdetail(@RequestParam("sid") Integer sid){
        return informationService.getdetail(sid);
    }
}

